package com.bdqn.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回统一的数据格式
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class RespBean {
    private Integer code;
    private String msg;
    private Object data;

     public RespBean(ResultEnum resultEnum){
         this.code=resultEnum.code;
         this.msg=resultEnum.getMsg();
     }
     //成功时候返回的bean对象
    public static RespBean ok(String msg, Object data){
        return new RespBean(1,msg,data);
    }
    //失败时候返回的bean对象
    public static RespBean error(String msg){
        return new RespBean(0,msg,null);
    }
}
